from greenlet import greenlet

import time

def mytest1():
    while True:
        print("----A----")
        gr2.switch()
        time.sleep(0.5)

def mytest2():
    while True:
        print("----B----")
        gr1.switch()
        time.sleep(0.5)


gr1 = greenlet(mytest1)
gr2 = greenlet(mytest2)
gr1.switch()
